﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ChineseSchool.BLL;
using ChineseSchool.Models.Hethong;

namespace ChineseSchool.UserControl.ThuNghiem
{
    public partial class Activities : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;
            lblActivities.Text = LoadActivities();
        }

        public string LoadActivities()
        {
            var strActivities = "";
            var lstActivities = new B_Activities().GetAlls(8);
            if (lstActivities != null && lstActivities.Count > 0)
            {
                foreach (var activities in lstActivities)
                {
                    string dayClass;
                    var dayofweek = activities.ActivitiesDate.DayOfWeek.ToString();
                    switch (dayofweek)
                    {
                        case "Monday":
                            dayClass = "mon";
                            break;
                        case "Tuesday":
                            dayClass = "tue";
                            break;
                        case "Wednesday":
                            dayClass = "wed";
                            break;
                        case "Thursday":
                            dayClass = "thu";
                            break;
                        case "Friday":
                            dayClass = "fri";
                            break;
                        case "Saturday":
                            dayClass = "sat";
                            break;
                        case "Sunday":
                            dayClass = "sun";
                            break;
                        default:
                            dayClass = "mon";
                            break;
                    }

                    strActivities += "<div class=\"activities col-xs-6 col-sm-4 col-md-3 col-lg-3\"> ";
                    strActivities += "<div class=\"tag " + dayClass + "\"> ";
                    strActivities += "<a href=\"" + Util.MakeLinkActivitiesDetail(activities.ActivitiesID.ToString(CultureInfo.InvariantCulture), Encode.Uni2KD(activities.ActivitiesTitle)) + "\">" + activities.ActivitiesDate.ToString("dd/MM/yyyy") + "</a></div>";
                    strActivities += "<a href=\"" + Util.MakeLinkActivitiesDetail(activities.ActivitiesID.ToString(CultureInfo.InvariantCulture), Encode.Uni2KD(activities.ActivitiesTitle)) + "\">" + activities.ActivitiesTitle + "</a>";
                    strActivities += "</div> ";
                }
            }
            return strActivities;
        }
    }
}